/*
* $Id: DatabaseManager.h 143 2010-09-09 19:55:18Z volok-aleksej@yandex.ru $
*
* Copyright 2008-2009 by Volokitin Alexey
* All rights reserved
*
*/
#ifndef _DATABASE_MANAGER_H_
#define _DATABASE_MANAGER_H_

interface IDatabase;
interface ITargetCommand;

struct DatabaseHandle
{
	std::tstring m_strDatabaseName;
	int m_nClient;
	DatabaseHandle(const std::tstring& strDatabaseName)
	{
		m_strDatabaseName = strDatabaseName;
		m_nClient = 0;
	}
	bool operator == (const DatabaseHandle& dh) const
	{
		return dh.m_strDatabaseName == m_strDatabaseName;
	}
	bool operator < (const DatabaseHandle& dh) const
	{
		return dh.m_strDatabaseName < m_strDatabaseName;
	}
};

class CDatabaseManager : public IDatabaseManager
{
	std::map<DatabaseHandle, IDatabase*> m_aOpenDatabases;
public:
	CDatabaseManager();
	~CDatabaseManager();

	virtual void Initialize();
	virtual IDatabase* OpenDatabase(const std::tstring& strNameDatabase);
	virtual void CloseDatabase(IDatabase* pDatabase);
};

#endif /*_DATABASE_MANAGER_H_*/